import React, { Component } from 'react'

export default class App extends Component {
    constructor() {
        super()
        this.state = {
            text: "收藏",
            condition: true
        }
    }
    render() {
        return (
            <div>
                <h1>欢迎来到React开发</h1>
                <button onClick={() => {
                    // this.setState({
                    //     condition: !this.state.condition
                    // })
                    this.setState((prevState, props) => {
                        console.log(prevState);
                        return {
                            condition: !prevState.condition
                        }
                    }, () => {
                        console.log('回调里的', this.state.condition)
                    })
                }}>{this.state.condition ? '收藏' : '取消收藏'}</button>
            </div>
        )
    }
}
